//
//  WelcomeViewController.swift
//  WBDemo
//
//  Created by Meng on 17/2/13.
//  Copyright © 2017年 demo. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {

    @IBOutlet weak var iconBottomConstraint: NSLayoutConstraint!
    
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var icon: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        guard let account = UserAccount.readUserAccount() else {
            MYLog("必须授权后才能显示欢迎界面")
            return
        }
        guard let url = URL(string: account.avatar_large!) else {
            return
        }
        self.icon.sd_setImage(with: url)
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.iconBottomConstraint.constant = 320;
        
        UIView.animate(withDuration: 1.0, animations: { 
            self.view.layoutIfNeeded()
        }) { (Bool) in
            self.label.alpha = 1.0
            DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: { 
                NotificationCenter.default.post(name: NSNotification.Name.init(SwitchRootViewController), object: true)
            })
        }
    }

}
